﻿using DevExpress.LookAndFeel;
using DevExpress.Skins;
using DevExpress.UserSkins;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace BmpForm1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // 启用大地址感知（64位系统）
            if (Environment.Is64BitProcess)
            {
                NativeMethods.EnableLargeAddresses();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        // NativeMethods类
        internal static class NativeMethods
        {
            [DllImport("kernel32.dll", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool SetProcessWorkingSetSize(IntPtr process,
                UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);

            public static void EnableLargeAddresses()
            {
                var process = Process.GetCurrentProcess().Handle;
                var min = new UIntPtr(0);
                var max = new UIntPtr(0x100000000); // 4GB
                SetProcessWorkingSetSize(process, min, max);
            }
        }
    }
}
